'use strict';

function compute_chain_median(collection) {
  let collection1=collection.split("->");
  let collection2=collection1.map(
    function maped(element){
      return parseInt(element);
    }
  );
  let collection3=collection2.sort(
    function sorted(a,b){
      return a-b;
    }
  );
  if(collection3.length%2===0){
    return (collection3[collection3.length/2]+collection3[collection3.length/2-1])/2;
  }
  else {
    return collection3[(collection3.length-1)/2];
  }
}

module.exports = compute_chain_median;
